/*
*  Copyright 2019-2025 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.transfer.rest;

import me.zhengjie.annotation.Log;
import me.zhengjie.modules.transfer.domain.TransferIc58;
import me.zhengjie.modules.transfer.service.TransferIc58Service;
import me.zhengjie.modules.transfer.domain.dto.TransferIc58QueryCriteria;
import lombok.RequiredArgsConstructor;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import me.zhengjie.utils.PageResult;

/**
* @author lzw
* @date 2025-05-26
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "pai")
@RequestMapping("/api/transferIc58")
public class TransferIc58Controller {

    private final TransferIc58Service transferIc58Service;

    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('transferIc58:list')")
    public void exportTransferIc58(HttpServletResponse response, TransferIc58QueryCriteria criteria) throws IOException {
        transferIc58Service.download(transferIc58Service.queryAll(criteria), response);
    }

    @GetMapping
    @ApiOperation("查询pai")
    @PreAuthorize("@el.check('transferIc58:list')")
    public ResponseEntity<PageResult<TransferIc58>> queryTransferIc58(TransferIc58QueryCriteria criteria){
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(transferIc58Service.queryAll(criteria,page),HttpStatus.OK);
    }

    @PostMapping
    @Log("新增pai")
    @ApiOperation("新增pai")
    @PreAuthorize("@el.check('transferIc58:add')")
    public ResponseEntity<Object> createTransferIc58(@Validated @RequestBody TransferIc58 resources){
        transferIc58Service.create(resources);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }

    @PutMapping
    @Log("修改pai")
    @ApiOperation("修改pai")
    @PreAuthorize("@el.check('transferIc58:edit')")
    public ResponseEntity<Object> updateTransferIc58(@Validated @RequestBody TransferIc58 resources){
        transferIc58Service.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @Log("删除pai")
    @ApiOperation("删除pai")
    @PreAuthorize("@el.check('transferIc58:del')")
    public ResponseEntity<Object> deleteTransferIc58(@ApiParam(value = "传ID数组[]") @RequestBody List<String> ids) {
        transferIc58Service.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    /**
     * 查询待转出人员支付表信息
     * @param resources
     * @return
     */
    @PostMapping("query")
    public ResponseEntity<Object> query( @RequestBody Map resources){
        return new ResponseEntity<>(transferIc58Service.query(resources),HttpStatus.OK);
    }

    /**
     * 查询支付表汇总信息
     * @param resources
     * @return
     */
    @PostMapping("querycount")
    public ResponseEntity<Object> querycount( @RequestBody Map resources){
        return new ResponseEntity<>(transferIc58Service.querycount(resources),HttpStatus.OK);
    }

    /**
     * 查询支付表汇总信息明细
     * @param resources
     * @return
     */
    @PostMapping("querydetail")
    public ResponseEntity<Object> querydetail( @RequestBody Map resources){
        return new ResponseEntity<>(transferIc58Service.querydetail(resources),HttpStatus.OK);
    }

    /**
     * 汇总支付表
     * @param resources
     * @return
     */
    @PostMapping("save")
    public ResponseEntity<Object> save( @RequestBody List<Map> resources) throws IOException {
        transferIc58Service.save(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

}
